//
//  YXYGroupHotSixCollectionViewCell.m
//  Topit
//
//  Created by dllo on 15/12/11.
//  Copyright © 2015年 YXY. All rights reserved.
//

#import "YXYGroupHotSixCollectionViewCell.h"

@implementation YXYGroupHotSixCollectionViewCell

-(void)dealloc {
    [_imageUrl release];
    [_myImage release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.myImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.myImage.contentMode = UIViewContentModeScaleAspectFill;
        self.myImage.clipsToBounds = YES;
        UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fangda)];
        singleTap.numberOfTapsRequired = 1;
        [_myImage addGestureRecognizer:singleTap];
        [self addSubview:_myImage];
        [_myImage release];
    }
    return self;
}

- (void)setImageUrl:(NSString *)imageUrl {
    if (_imageUrl != imageUrl) {
        [_imageUrl release];
        _imageUrl = [imageUrl retain];
    }
    if (imageUrl) {
        [_myImage sd_setImageWithURL:[NSURL URLWithString:imageUrl]];
        [_myImage nightMode];
    }else {
        _myImage.image = nil;
    }
   
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _myImage.frame = CGRectMake(1, 0, self.width - 5, self.height - 5);
}

- (void)fangda {
   
    UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 8, 200, 200)];
    imgView = self.myImage;
    [SJAvatarBrowser showImage:imgView];
}

@end
